package json;

import base.User;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;

public class JacksonDemo {
    public static void main(String[] args) throws JsonProcessingException {
        User user = new User();
        user.setName("abc");
        user.setAge(11);

        ObjectMapper mapper = new ObjectMapper();
        String s = mapper.writeValueAsString(user);
        System.out.println("s = " + s);

        User user1 = mapper.readValue(s, User.class);
        System.out.println("user1 = " + user1);
    }
}
